<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/include/tagLib.jsp" %>
<!doctype html>
<html lang="en">
<head>
    <title>${sieName}</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <%@include file="/include/cssLib.jsp" %>
</head>

<body>
<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <!-- 菜单 -->
            <tag:nav key="sysAdmin"/>

            <div class="tab-content">
                <div class="tab-pane active">
                    <div class="card col-md-10 col-md-offset-1">
                        <tag:sys-nav key="eventList"/>
                        <div class="card-header">
                            <div class="row">
                                <form id="searchForm" action="${ctx}/adminConsole/system/eventList" method="post">
                                    <div class="col-md-2">
                                        <input type="text" name="QF__EQ__key" value="${searchCondMap['QF__EQ__key']}" class="form-control clearable" placeholder="KEY"/>
                                    </div>
                                    <div class="col-md-2">
                                        <input type="text" name="QF__EQ__producer" value="${searchCondMap['QF__EQ__producer']}" class="form-control clearable" placeholder="生产者"/>
                                    </div>
                                    <div class="col-md-1">
                                        <button type="submit" class="btn btn-twitter"><i class="fa fa-search"></i></button>
                                        <input type="hidden" id="pageNo" name="pageNo"/>
                                        <input type="hidden" id="pageSize" name="pageSize" />
                                        <input type="hidden" id="orderBy" name="page.orderBy" value="${orderBean.orderBy}"/>
                                        <input type="hidden" id="order" name="page.order" value="${orderBean.order}"/>
                                    </div>
                                </form>
                            </div>
                        </div>
                        <div class="card-content">
                            <div class="table-responsive">
                                <table class="table table-bordered table-hover">
                                    <thead>
                                    <tr>
                                        <th>ID</th>
                                        <th>KEY</th>
                                        <th>描述</th>
                                        <th>json参数</th>
                                        <th>生产者</th>
                                        <th sort-field="create_time">创建时间</th>
                                        <th>状态</th>
                                        <th>操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <c:forEach items="${pageResult.result }" var="data">
                                        <tr>
                                            <td>${data.id}</td>
                                            <td>${data.eventKey}</td>
                                            <td>${data.desc}</td>
                                            <td>${data.paramJson}</td>
                                            <td>${data.producer}</td>
                                            <td>${fns:formatDateTime(data.createTime)}</td>
                                            <td>
                                                <c:if test="${data.status eq 1}"><label class="label label-success">处理完毕</label></c:if>
                                                <c:if test="${data.status eq 0}"><label class="label label-info">待处理</label></c:if>
                                            </td>
                                            <td>
                                                <a  href="javascript:;" onclick="view('${data.eventKey}')">消费记录</a>
                                            </td>
                                        </tr>
                                    </c:forEach>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                        <tag:paging page="${pageResult}"/>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<%@include file="/include/sidebarRight.jsp" %>
</body>
<%@include file="/include/scriptLib.jsp" %>
<script type="text/javascript">
    $(document).ready(function() {
        //绑定排序
        FormUtil.bindOrder();
    });

    function view(eventKey){
        HttpUtil.ajaxAsyncJsonPost('/adminConsole/system/eventConsumeList', {eventKey: eventKey}, function(dataArray){
            if(CommUtil.isEmpty(dataArray)){
                dialogTip('无消费记录');
            }else{
                var html = new StringBuffer();
                html.append("<table class='table table-bordered'>");
                html.append("<thead><tr><th>消费者</th><th>消费时间</th></tr></thead>");
                html.append("<tbody>");
                var item = null;
                for(i=0; i<dataArray.length; i++){
                    item = dataArray[i];
                    html.append("<tr><td>"+item.consumer+"</td><td>"+DateUtil.formatTimeToDateStr(item.createTime)+"</td></tr>");
                }
                html.append("</tbody></table>");
                dialogOpenPageViewHtml('消费历史', html.toString(), 400, 400);
            }
        });
    }
</script>

</html>